/* -----------------------------------------------------------------------
 * Demonstration of how to write unit tests for dominion-base
 * Include the following lines in your makefile:
 *
 * testHandCard: testHandCard.c dominion.o rngs.o
 *      gcc -o testHandCard -g  testHandCard.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
    int seed = 500;
    int numPlayer = 2;
    int p, r, handCount;
	int x, y;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 5;

/*	int coppers[MAX_HAND];
    int silvers[MAX_HAND];
    int golds[MAX_HAND];

   for (i = 0; i < MAX_HAND; i++)
    {
        coppers[i] = copper;
        silvers[i] = silver;
        golds[i] = gold;
    }*/

	memset(&G, 23, sizeof(struct gameState));   // clear the game state
	r = initializeGame(numPlayer, k, seed, &G); // initialize a new game

    printf ("TESTING handCard():\n");
    for (p = 0; p < numPlayer; p++)
    {
        for (handCount = 1; handCount <= maxHandCount; handCount++)
        {
			#if (NOISY_TEST == 1)
				printf("Testing card value at position %d in the hand of player %d.\n", handCount, p);
			#endif

          //  memcpy(G.hand[p], coppers, sizeof(int) * handCount); // set all the cards to copper 
			x = handCard(handCount - 1, &G); // get the index number of the card based on the enum CARD in dominion.h
			y = G.hand[p][handCount - 1]; // get the index number of the card directly

			#if (NOISY_TEST == 1)
                printf("Card ENUM = %d. Expected = %d\n", x, y);
			#endif
			assert(x >= curse && x <= treasure_map);
        }
		printf("\n");
		endTurn(&G);
    }

    printf("All handCard tests completed!\n");

    return 0;
}